package com.xiaoma.chat.dto;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.xiaoma.chat.resource.GroupType;
import com.xiaoma.chat.resource.Organization;

public class GroupDto {

    private String name;
    private String description;
    private Integer organizationId;
    private Integer ownerId;
    private Integer type;
    private List<UserMetaData> adminMetaDatas = new ArrayList<UserMetaData>();
    private List<UserMetaData> teacherMetaDatas = new ArrayList<UserMetaData>();
    
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getOrganizationId() {
        return organizationId;
    }
    public void setOrganizationId(Integer organizationId) {
        this.organizationId = organizationId;
    }
    public Integer getOwnerId() {
        return ownerId;
    }
    public void setOwnerId(Integer ownerId) {
        this.ownerId = ownerId;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    
    public List<UserMetaData> getTeacherMetaDatas() {
        return teacherMetaDatas;
    }
    public void setTeacherMetaDatas(List<UserMetaData> teacherMetaDatas) {
        this.teacherMetaDatas = teacherMetaDatas;
    }
    public List<UserMetaData> getAdminMetaDatas() {
        return adminMetaDatas.size() > 5 ? this.adminMetaDatas.subList(0, 5) : adminMetaDatas;//最多传5个管理员;
    }
    public void setAdminMetaDatas(List<UserMetaData> adminMetaDatas) {
        this.adminMetaDatas = adminMetaDatas;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    
    public boolean validate() {
        return StringUtils.isNotEmpty(this.name) && (null != this.organizationId) 
                && (Organization.isExist(this.organizationId)) && (this.ownerId != null)
                && (null != this.type) && (GroupType.isExist(this.type));
//                && (this.adminMetaDatas.size() + this.teacherMetaDatas.size() + 1) <= 100;
    }
    
}
